package ui.activity;

import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.view.MenuItem;

import com.wyz.troika_test.R;

import butterknife.BindView;
import presenter.BasePresenter;

/**
 * Created by 10153 on 2018/8/5.
 */

public abstract class BaseDrawerActivity<P extends BasePresenter> extends BaseActivity<P>
        implements NavigationView.OnNavigationItemSelectedListener{
    
    @BindView(R.id.drawer_layout) DrawerLayout mDrawerLayout;
    @BindView(R.id.nav_view) NavigationView mNavigationView;
    
    @Override
    protected void init() {
        super.init();
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolBar,
                                                                 R.string.navigation_drawer_open,
                                                                 R.string.navigation_drawer_close);
        mDrawerLayout.addDrawerListener(toggle);
        toggle.syncState();
        mNavigationView.setNavigationItemSelectedListener(this);
    }
    
    @Override
    public boolean onNavigationItemSelected(@NonNull MenuItem item) {
        int id = item.getItemId();
    
        if (id == R.id.nav_summery) {
            // Handle the camera action
        } else if (id == R.id.nav_advice) {
//            Intent intent = new Intent(this, AdviceActivity.class);
//            startActivity(intent);
        } else if (id == R.id.nav_setting) {
        
        }
    
        mDrawerLayout.closeDrawer(GravityCompat.START);
        return true;
    }
}
